﻿using System.Web.Mvc;
using System.Web.Routing;

namespace SimpleServiceBus.EndpointMonitor.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",
                "",
                new {controller = "Endpoint", action = "All"});

            routes.MapRoute(
                "EndpointAnalyticsRoute",
                "Endpoints/{endpointId}/Analytics/{action}",
                new {controller = "Endpoint", action = "TimeSeries"});


            routes.MapRoute(
                    "EndpointErrorRoute",
                    "Endpoints/{endpointId}/Errors/{errorId}",
                    new { controller = "Endpoint", action="ErrorDetail", errorId = "All"}
                );

            routes.MapRoute(
                    "EndpointErrorRouteByDate",
                    "Endpoints/{endpointId}/Errors/{year}/{month}/{day}",
                    new {controller="Endpoint",action="ErrorsByDate"}
                );

            routes.MapRoute(
                    "DefaultEndpointRoute",
                    "Endpoints/{endpointId}",
                    new { controller = "Endpoint", action="Detail", endpointId = "All"}
                );
            //routes.MapRoute(
            //    "Default",                                              // Route name
            //    "{controller}/{action}/{id}",                           // URL with parameters
            //    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            //);

        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }

        protected void Application_BeginRequest()
        {
            
        }

        protected void Application_EndRequest()
        {
        }
    }
}